package com.project.controller;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.entity.sys.Area;
import com.project.entity.sys.User;
import com.project.service.sys.AreaService;
import com.project.util.CurrentSessionUtil;

@Controller
@RequestMapping("admin")
public class IndexController{
	
	@Autowired
	private AreaService areaService;

	
	@RequestMapping("/index")
	public String index(Model model){
		User currentUser = CurrentSessionUtil.getCurrentUser();
		model.addAttribute("currentUser", currentUser);
		return "/index";
	}
	
	@RequestMapping(value="getProvinceList")
	@ResponseBody
	public List<Area> getProvinceList(){
		return areaService.getProvinceList();
	}
	
	//根据省code获取市List
	@RequestMapping(value="getChildList")
	@ResponseBody
	public List<Area> getCityListByProvince(@RequestParam String code){
		return areaService.getChildList(code);
	}
	

}
